<template>
  <section>
    <div class="custorm--modelbox goodstitle-edit">
      <renohome-right-nav :custormItemData="custormItemData" @rightNavChange="rightNavChange" showChange="1"></renohome-right-nav>
      <section v-if="nrActive">
        <div class="edit-form-item">
          <div class="form-label">主标题</div>
          <div class="stylebox flex-row flex-align-c ivu-color-picker"><span style="margin-right:13px;">颜色</span>
            <el-color-picker class="ivu-input" v-model="custormItemData.style.maincolor" size="mini"></el-color-picker>
            <span class="ivu-input">{{custormItemData.style.maincolor}}</span>
          </div>
          <div class="stylebox flex-row flex-align-c"><span style="margin-right:13px;">文字</span>
            <el-input v-model="custormItemData.params.maintext" size="small">
              <!-- <i slot="suffix" style="line-height: 32px;">
                {{custormItemData.params.maintext.length}}/8</i> -->
            </el-input>
          </div>
        </div>

        <div class="edit-form-item">
          <div class="form-label">副标题</div>
          <div class="stylebox flex-row flex-align-c ivu-color-picker"><span style="margin-right:13px;">颜色</span>
            <el-color-picker class="ivu-input" v-model="custormItemData.style.subcolor" size="mini"></el-color-picker>
            <span class="ivu-input">{{custormItemData.style.subcolor}}</span>
          </div>
          <div class="stylebox flex-row flex-align-c"><span style="margin-right:13px;">文字</span>
            <el-input v-model="custormItemData.params.subtext" size="small">
              <!-- <i slot="suffix" style="line-height: 32px;">
                {{custormItemData.params.subtext.length}}/8</i> -->
            </el-input>
          </div>
        </div>

        <div class="edit-form-item" v-if="custormItemData.style.display == '1'">
          <div class="form-label">查看更多</div>
          <div class="stylebox flex-row flex-align-c ivu-color-picker"><span style="margin-right:13px;">显隐</span>
            <el-radio-group v-model="custormItemData.params.showmore" class="flex-row mar-15">
              <el-radio label="1">显示</el-radio>
              <el-radio label="2">隐藏</el-radio>
            </el-radio-group>
          </div>
          <div class="stylebox flex-row flex-align-c ivu-color-picker" v-if="custormItemData.params.showmore == 1"><span style="margin-right:13px;">颜色</span>
            <el-color-picker class="ivu-input" v-model="custormItemData.style.morecolor" size="mini"></el-color-picker>
            <span class="ivu-input">{{custormItemData.style.morecolor}}</span>
          </div>
          <div class="stylebox flex-row flex-align-c" v-if="custormItemData.params.showmore == 1"><span style="margin-right:13px;">链接</span>
            <div class="readonly-div" @click="uploadtoggle">
              <div class="readonly ivu-input-wrapper ivu-input-wrapper-default ivu-input-type">
                <input autocomplete="off" spellcheck="false" type="text" placeholder="请选择链接" readonly="readonly" class="ivu-input ivu-input-default" :value="typeof custormItemData.params.link === 'string' ? custormItemData.params.link : custormItemData.params.link.path">
              </div> <i class="icon icon-fujian readonly-icon" style="left: 12px;margin-top:-3px;"></i>
            </div>
          </div>
        </div>

        <div class="edit-form-item">
          <div class="form-label" style="margin-top: 20px;">上下边距</div>
          <div class="flex-row flex-align-c">
            <el-slider :show-tooltip="false" style="width: 70%;" v-model="margincol" input-size="mini" :max="48">
            </el-slider>
            <div class="coupon-showslider">{{custormItemData.style.margincol}}px</div>
          </div>
          <div class="form-label" style="margin-top: 20px;" v-if="custormItemData.style.display != 3">左右边距</div>
          <div class="flex-row flex-align-c" v-if="custormItemData.style.display != 3">
            <el-slider :show-tooltip="false" style="width: 70%;" v-model="marginrow" input-size="mini" :max="48">
            </el-slider>
            <div class="coupon-showslider">{{custormItemData.style.marginrow}}px</div>
          </div>
        </div>
      </section>
      <section v-if="fgActive">
        <div class="edit-form-item">
          <div class="es-form-item">
            <div class="item-inner block">
              <label class="button-img block" @click="changePattern(1)" v-bind:class="{active:custormItemData.style.display==1}">
                <div class="es-title title1">
                  <div class="flex-row flex-justify-b flex-align-c">
                    <div class="title-content">
                      <div class="main-title">这是主标题</div>
                      <div class="sub-title">这是副标题</div>
                    </div>
                    <div class="title-more">查看更多</div>
                  </div>
                </div>
              </label>
            </div>
            <div class="item-inner block">
              <label class="button-img block" @click="changePattern(2)" v-bind:class="{active:custormItemData.style.display==2}">
                <div class="es-title title2">
                  <div class="flex-row">
                    <div class="main-title">这是主标题</div>
                    <div class="sub-title">这是副标题</div>
                  </div>
                </div>
              </label>
            </div>
            <div class="item-inner block">
              <label class="button-img block" @click="changePattern(3)" v-bind:class="{active:custormItemData.style.display==3}">
                <div class="es-title title3">
                  <div class="flex-col flex-justify-c flex-align-c">
                    <div class="main-title flex-row flex-align-c">
                      <span></span>
                      <div>这是主标题</div>
                      <span></span>
                    </div>
                    <div class="sub-title">这是副标题</div>
                  </div>
                </div>
              </label>
            </div>
          </div>
        </div>
      </section>
    </div>
  </section>
</template>

<script>
import defaultConfig from './utils/editConfig'
export default {
  mixins: [defaultConfig.mixins],
  props: {
    defaultConfig: {
      type: Object,
      default: function() {
        return defaultConfig
      }
    }
  },
  computed: {
    margincol: {
      set(value) {
        this.custormItemData.style.margincol = value
      },
      get() {
        return this.conversionType('number', this.custormItemData.style.margincol)
      }
    },
    marginrow: {
      set(value) {
        this.custormItemData.style.marginrow = value
      },
      get() {
        return this.conversionType('number', this.custormItemData.style.marginrow)
      }
    }
  },
  methods: {
    uploadFileCallBack(files) {
      const { key } = files
      if (key === 'ChooseLink') {
        const { currentRow: [file_path], displayData: [custorm] } = files
        if (file_path) {
          this.custormItemData.params.link = file_path
        } else {
          if (custorm) {
            this.custormItemData.params.link = custorm
          } else {
            this.$message.error('请选择链接~!')
          }
        }
      }
    },
    uploadtoggle() {
      this.output({ type: 'link', params: { editKey: this.custormItemData.key }})
    }
  }
}
</script>

<style lang="scss" scoped>
.custorm--modelbox.goodstitle-edit {
  .es-form-item {
    border-bottom: 5px solid #f6f7f9;
    padding: 20px 23px;
    font-size: 12px;
  }

  .es-form-item .item-inner {
    margin-top: 8px;
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
  }

  .es-form-item .item-inner:first-of-type {
    margin-top: 0;
  }

  .button-img {
    box-sizing: border-box;
    width: 32px;
    height: 32px;
    margin-right: 20px;
    cursor: pointer;
    border-radius: 4px;
    line-height: 36px;
    text-align: center;
    border: 1px solid transparent;
  }

  .button-img.block {
    width: 100%;
    position: relative;
    min-height: 32px;
    height: auto;
    padding: 10px;
    text-align: left;
  }

  .es-title {
    margin: 12px;
    font-size: 16px;
  }

  .es-title .title-more {
    font-size: 13px;
    color: #999999;
    font-weight: normal;
  }

  .es-title,
  .es-title.title2,
  .es-title.title12,
  .es-title.title13 {
    position: relative;
  }

  .button-img .es-title {
    margin: 0;
    line-height: 1.5;
  }

  .es-title.title1 .title,
  .es-title.title12 .title,
  .es-title.title13 .title {
    padding: 0 10px;
    position: relative;
    background: #fff;
    z-index: 2;
  }

  .es-title .sub-title {
    font-size: 13px;
    color: #999999;
    font-weight: normal;
  }

  .es-title.title2 {
    .flex-row {
      align-items: baseline;
    }
    .sub-title {
      margin-left: 6px;
    }
  }

  .es-title.title3 {
    .main-title span {
      display: inline-block;
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: #ffd940;
      border: 1px solid transparent;
      position: relative;
      margin: 0 10px;
    }
    .main-title span::after {
      content: " ";
      position: absolute;
      top: -2px;
      left: -2px;
      width: 5px;
      height: 5px;
      border: 1px solid #333333;
      border-radius: 50%;
    }
  }

  .ivu-input-wrapper {
    display: inline-block;
    width: 100%;
    position: relative;
    vertical-align: middle;
    line-height: normal;
  }

  .readonly-div {
    position: relative;
    flex-grow: 1;
  }

  .readonly-div .readonly input {
    background: #e8effc;
    border: 0;
    padding-left: 18px;
    cursor: pointer;
    box-sizing: border-box;
    display: inline-block;
    width: 100%;
    height: 32px;
    line-height: 1.5;
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 4px;
  }
}
</style>
